package com.doradance.account.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.doradance.R;
import com.doradance.app.home.CoursesDetailActivity;
import com.doradance.app.home.VipRechargeActivity;

/**
 * Created by Administrator on 2018/3/13.
 */

public class VipDialogUtil {

    public static void DetailDialog(final Context mContext,String title,String comfirm){
        LayoutInflater factory = LayoutInflater.from(mContext);
        View inflate = factory.inflate(R.layout.no_member_dialog, null);
        TextView tvDialogTitle = (TextView) inflate.findViewById(R.id.tv_dialog_title);
        TextView tvBecomeVip = (TextView) inflate.findViewById(R.id.tv_become_vip);
        tvDialogTitle.setText(title);
        tvBecomeVip.setText(comfirm);
        final AlertDialog isMemberDialog = new AlertDialog.Builder(mContext)
                .setView(inflate).create();
        inflate.findViewById(R.id.tv_no_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                isMemberDialog.cancel();
            }
        });
        inflate.findViewById(R.id.tv_become_vip).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                VipRechargeActivity.start(mContext,-1+"");
                isMemberDialog.cancel();
            }
        });
        //设置点击Dialog外部任意区域关闭Dialog
        isMemberDialog.setCanceledOnTouchOutside(true);
        isMemberDialog.show();
    }

    public static void Is3GDialog(final Context mContext,String title,String comfirm,String cancel){
        LayoutInflater factory = LayoutInflater.from(mContext);
        View inflate = factory.inflate(R.layout.no_member_dialog, null);
        TextView tvDialogTitle = (TextView) inflate.findViewById(R.id.tv_dialog_title);
        TextView tvBecomeVip = (TextView) inflate.findViewById(R.id.tv_become_vip);
        TextView tvNoVip = (TextView) inflate.findViewById(R.id.tv_no_cancel);
        tvDialogTitle.setText(title);
        tvBecomeVip.setText(comfirm);
        tvNoVip.setText(cancel);
        final AlertDialog isMemberDialog = new AlertDialog.Builder(mContext)
                .setView(inflate).create();
        inflate.findViewById(R.id.tv_no_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                isMemberDialog.cancel();
            }
        });
        inflate.findViewById(R.id.tv_become_vip).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                VipRechargeActivity.start(mContext,-1+"");
                isMemberDialog.cancel();
            }
        });
        //设置点击Dialog外部任意区域关闭Dialog
        isMemberDialog.setCanceledOnTouchOutside(true);
        isMemberDialog.show();
    }


    public static void LearnDialog(final Context mContext,String title,String comfirm,final int type){
        LayoutInflater factory = LayoutInflater.from(mContext);
        View inflate = factory.inflate(R.layout.no_member_dialog, null);
        TextView tvDialogTitle = (TextView) inflate.findViewById(R.id.tv_dialog_title);
        TextView tvBecomeVip = (TextView) inflate.findViewById(R.id.tv_become_vip);
        tvDialogTitle.setText(title);
        tvBecomeVip.setText(comfirm);
        final AlertDialog isMemberDialog = new AlertDialog.Builder(mContext)
                .setView(inflate).create();
        inflate.findViewById(R.id.tv_no_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                isMemberDialog.cancel();
            }
        });
        inflate.findViewById(R.id.tv_become_vip).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                VipRechargeActivity.start(mContext);
                if(type ==0){
                    isMemberDialog.cancel();
                }else{
                    CoursesDetailActivity.start1(mContext,type);
                    isMemberDialog.cancel();
                }

            }
        });
        //设置点击Dialog外部任意区域关闭Dialog
        isMemberDialog.setCanceledOnTouchOutside(true);
        isMemberDialog.show();
    }



}
